//
//  CouponDetailFV.m
//  penzer
//
//  Created by 还带大道 on 2018/11/9.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "CouponDetailFV.h"
@interface CouponDetailFV()

@property (weak, nonatomic) IBOutlet UIButton *lastView;
@property (weak, nonatomic) IBOutlet UILabel *ruleDesc;
@end

@implementation CouponDetailFV

+ (instancetype)shareView
{
    return [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].lastObject;
}

- (void)awakeFromNib
{
    [super awakeFromNib];
    [self bindData];
}


- (void)bindData
{
    NSString *contentStr = @"1、中国移动用户，均可使用银行卡充值业务。\n2、所有标有移动的营业厅均可充值。\n3、移动用户仅限于每月充值1次。\n4、扫码核销后，所充值金额一般将于10分钟左右到账，遇系统繁忙等情况可能会存在延时到账，充值成功以后，会收到中国移动给您发送的充值短信，如未收到短信，请拨打10086查询。";
    if(contentStr && contentStr.length>0){
        NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
        paragraph.lineSpacing = 5; //设置行间距
        paragraph.alignment = NSTextAlignmentLeft;
        NSDictionary *attributeDict = @{
                                        NSFontAttributeName:[UIFont systemFontOfSize:14],
                                        NSForegroundColorAttributeName:RZ_COLOR(155, 155, 155),
                                        NSKernAttributeName:@0,//字符间距
                                        NSParagraphStyleAttributeName:paragraph};
        
        NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:contentStr attributes:attributeDict];
            _ruleDesc.attributedText = attributeStr;
    }
    [self layoutIfNeeded];
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat height = CGRectGetMaxY(self.lastView.frame)+20;
    !self.refreshBlock?:self.refreshBlock(height);
}

@end
